package com.cruise.game.common.config;

import com.baomidou.mybatisplus.core.config.GlobalConfig;
// 移除不需要的导入
// import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
// import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis Plus 配置
 *
 * @author cruise
 * @date 2025-02-28
 */
@Configuration
public class MyBatisConfig {

    /**
     * 删除重复的分页插件配置，因为已经在MybatisPlusConfig中配置过了
     */
    /*
     * @Bean(name = "customMybatisPlusInterceptor")
     * public MybatisPlusInterceptor mybatisPlusInterceptor() {
     * MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
     * interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
     * return interceptor;
     * }
     */

    /**
     * 全局配置
     */
    @Bean(name = "customGlobalConfig")
    public GlobalConfig globalConfig() {
        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.setEnableSqlRunner(true);

        // 禁用逻辑删除
        GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
        dbConfig.setLogicDeleteField(null);
        globalConfig.setDbConfig(dbConfig);

        return globalConfig;
    }
}